package com.gzx.plugin.tjzy.modular.allocate.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.modular.allocate.entity.bo.GzxAllocateRecordAddOrEditBo;
import com.gzx.plugin.tjzy.modular.allocate.entity.bo.GzxAllocateRecordQueryBo;
import com.gzx.plugin.tjzy.modular.allocate.entity.vo.GzxAllocateRecordVo;
import com.gzx.plugin.tjzy.modular.allocate.service.GzxAllocateRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

/**
 * @author zjt
 * @description 分案记录
 * @date 2024/9/20 下午1:31
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/tjzy/allocate")
public class GzxAllocateRecordController {

    private final GzxAllocateRecordService allocateCaseLogService;

    /**
     * 获取案件详情页分案记录
     *
     * @param allocateRecordQueryBo 查询条件
     * @return
     */
    @PostMapping("/pageList")
    public CommonResult<Page<GzxAllocateRecordVo>> pageList(@RequestBody GzxAllocateRecordQueryBo allocateRecordQueryBo) {
        return CommonResult.data(allocateCaseLogService.pageList(allocateRecordQueryBo));
    }

    /**
     * 案件分配、案件回收
     *
     * @param allocateRecordAddOrEditBo 案件ID
     * @return
     */
    @CommonLog("案件分配/回收")
    @PostMapping("/updateCaseMediator")
    public CommonResult<Void> updateCaseMediator(@RequestBody GzxAllocateRecordAddOrEditBo allocateRecordAddOrEditBo) {
        allocateCaseLogService.updateCaseMediator(allocateRecordAddOrEditBo);
        return CommonResult.ok();
    }

    @CommonLog("Excel分案")
    @PostMapping("/importAllocate")
    public CommonResult<Void> excelAllocate(MultipartFile file) {
        allocateCaseLogService.excelAllocate(file);
        return CommonResult.ok();
    }

}
